/*
 * Copyright 2020-2030 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package com.gitee.minimalismstyle.fresh.flowable.api.feign

import org.springframework.web.bind.annotation.*
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.flowable.api.annotation.FlowableClient
import com.gitee.minimalismstyle.fresh.flowable.api.config.FlowableFeignConfig
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.DataResponse
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.HistoricTaskInstanceQueryRequest
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.HistoricTaskInstanceResponse
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.HistoricTaskLogEntryResponse

/**
 * HistoryTask
 * @author maoxiaodong
 */
@FlowableClient(configuration = [FlowableFeignConfig::class])
interface HistoryTaskApi {


    /**
     * List historic task instances
     */
    @GetMapping("/history/historic-task-instances")
    fun listHistoricTaskInstances(
        @RequestParam(name = "taskId", required = false) taskId: String?,
        @RequestParam(name = "processInstanceId", required = false) processInstanceId: String?,
        @RequestParam(name = "processInstanceIdWithChildren", required = false) processInstanceIdWithChildren: String?,
        @RequestParam(name = "processDefinitionKey", required = false) processDefinitionKey: String?,
        @RequestParam(name = "processDefinitionKeyLike", required = false) processDefinitionKeyLike: String?,
        @RequestParam(name = "processDefinitionId", required = false) processDefinitionId: String?,
        @RequestParam(name = "processDefinitionName", required = false) processDefinitionName: String?,
        @RequestParam(name = "processDefinitionNameLike", required = false) processDefinitionNameLike: String?,
        @RequestParam(name = "processBusinessKey", required = false) processBusinessKey: String?,
        @RequestParam(name = "processBusinessKeyLike", required = false) processBusinessKeyLike: String?,
        @RequestParam(name = "executionId", required = false) executionId: String?,
        @RequestParam(name = "taskDefinitionKey", required = false) taskDefinitionKey: String?,
        @RequestParam(name = "taskDefinitionKeys", required = false) taskDefinitionKeys: String?,
        @RequestParam(name = "taskName", required = false) taskName: String?,
        @RequestParam(name = "taskNameLike", required = false) taskNameLike: String?,
        @RequestParam(name = "taskDescription", required = false) taskDescription: String?,
        @RequestParam(name = "taskDescriptionLike", required = false) taskDescriptionLike: String?,
        @RequestParam(name = "taskCategory", required = false) taskCategory: String?,
        @RequestParam(name = "taskDeleteReason", required = false) taskDeleteReason: String?,
        @RequestParam(name = "taskDeleteReasonLike", required = false) taskDeleteReasonLike: String?,
        @RequestParam(name = "taskAssignee", required = false) taskAssignee: String?,
        @RequestParam(name = "taskAssigneeLike", required = false) taskAssigneeLike: String?,
        @RequestParam(name = "taskOwner", required = false) taskOwner: String?,
        @RequestParam(name = "taskOwnerLike", required = false) taskOwnerLike: String?,
        @RequestParam(name = "taskInvolvedUser", required = false) taskInvolvedUser: String?,
        @RequestParam(name = "taskCandidateGroup", required = false) taskCandidateGroup: String?,
        @RequestParam(name = "taskPriority", required = false) taskPriority: String?,
        @RequestParam(name = "finished", required = false) finished: Boolean?,
        @RequestParam(name = "processFinished", required = false) processFinished: Boolean?,
        @RequestParam(name = "parentTaskId", required = false) parentTaskId: String?,
        @RequestParam(name = "dueDate", required = false) dueDate: String?,
        @RequestParam(name = "dueDateAfter", required = false) dueDateAfter: String?,
        @RequestParam(name = "dueDateBefore", required = false) dueDateBefore: String?,
        @RequestParam(name = "withoutDueDate", required = false) withoutDueDate: Boolean?,
        @RequestParam(name = "taskCompletedOn", required = false) taskCompletedOn: String?,
        @RequestParam(name = "taskCompletedAfter", required = false) taskCompletedAfter: String?,
        @RequestParam(name = "taskCompletedBefore", required = false) taskCompletedBefore: String?,
        @RequestParam(name = "taskCreatedOn", required = false) taskCreatedOn: String?,
        @RequestParam(name = "taskCreatedBefore", required = false) taskCreatedBefore: String?,
        @RequestParam(name = "taskCreatedAfter", required = false) taskCreatedAfter: String?,
        @RequestParam(name = "includeTaskLocalVariables", required = false) includeTaskLocalVariables: Boolean?,
        @RequestParam(name = "includeProcessVariables", required = false) includeProcessVariables: Boolean?,
        @RequestParam(name = "scopeDefinitionId", required = false) scopeDefinitionId: String?,
        @RequestParam(name = "scopeId", required = false) scopeId: String?,
        @RequestParam(name = "scopeType", required = false) scopeType: String?,
        @RequestParam(name = "propagatedStageInstanceId", required = false) propagatedStageInstanceId: String?,
        @RequestParam(name = "tenantId", required = false) tenantId: String?,
        @RequestParam(name = "tenantIdLike", required = false) tenantIdLike: String?,
        @RequestParam(name = "withoutTenantId", required = false) withoutTenantId: Boolean?
    ): R<DataResponse<HistoricTaskInstanceResponse>>

    /**
     * Get a single historic task instance
     */
    @GetMapping("/history/historic-task-instances/{taskId}")
    fun getTaskInstance(
        @PathVariable("taskId") taskId: String
    ): R<HistoricTaskInstanceResponse>

    /**
     * Delete a historic task instance
     */
    @DeleteMapping("/history/historic-task-instances/{taskId}")
    fun deleteTaskInstance(
        @PathVariable("taskId") taskId: String
    ): R<Any>

    /**
     * Get a historic task instance form
     */
    @GetMapping("/history/historic-task-instances/{taskId}/form")
    fun getHistoricTaskForm(
        @PathVariable("taskId") taskId: String
    ): R<Any>

    /**
     * List identity links of a historic task instance
     */
    @GetMapping("/history/historic-task-instances/{taskId}/identitylinks")
    fun listHistoricTaskInstanceIdentityLinks(
        @PathVariable("taskId") taskId: String
    ): R<Any>

    /**
     * List historic task log entries
     */
    @GetMapping("/history/historic-task-log-entries")
    fun getHistoricTaskLogEntries(
        @RequestParam(name = "taskId", required = false) taskId: String?,
        @RequestParam(name = "type", required = false) type: String?,
        @RequestParam(name = "userId", required = false) userId: String?,
        @RequestParam(name = "processInstanceId", required = false) processInstanceId: String?,
        @RequestParam(name = "processDefinitionId", required = false) processDefinitionId: String?,
        @RequestParam(name = "scopeId", required = false) scopeId: String?,
        @RequestParam(name = "scopeDefinitionId", required = false) scopeDefinitionId: String?,
        @RequestParam(name = "subScopeId", required = false) subScopeId: String?,
        @RequestParam(name = "scopeType", required = false) scopeType: String?,
        @RequestParam(name = "from", required = false) from: String?,
        @RequestParam(name = "to", required = false) to: String?,
        @RequestParam(name = "tenantId", required = false) tenantId: String?,
        @RequestParam(name = "fromLogNumber", required = false) fromLogNumber: String?,
        @RequestParam(name = "toLogNumber", required = false) toLogNumber: String?
    ): R<DataResponse<HistoricTaskLogEntryResponse>>

    /**
     * All supported JSON parameter fields allowed are exactly the same as the parameters found for getting a collection of historic task instances, but passed in as JSON-body arguments rather than URL-parameters to allow for more advanced querying and preventing errors with request-uri’s that are too long. On top of that, the query allows for filtering based on process variables. The taskVariables and processVariables properties are JSON-arrays containing objects with the format as described here.
     */
    @PostMapping("/query/historic-task-instances")
    fun queryHistoricTaskInstance(
        @RequestBody(required = false) body: HistoricTaskInstanceQueryRequest?
    ): R<DataResponse<HistoricTaskInstanceResponse>>
}